<template>
  <view class="card padding-30 margin-top-14">
    <l-title title="车辆信息" />

    <view class="margin-top-30">
      <order-info-item label="公司" :value="orderInfo.autoCompanyName" />
      <template v-if="!orderInfo.outwardVehicleRealPrice">
        <order-info-item label="车型" :value="vehicleType" />
        <order-info-item label="车牌号" :value="orderInfo.vehicleId ? orderInfo.autoNumber : '暂无'" />
      </template>

      <order-info-item v-if="orderInfo.outwardVehicleRealPrice" label="座位数" :value="orderInfo.seatNum || '暂无'" />
      <order-info-item v-if="!orderInfo.vehicleId" label="司机" :value="!orderInfo.driverName && orderInfo.driverName != 'undefined' && orderInfo.driverName != undefined && orderInfo.driverName != 'null' ? orderInfo.driverName+'26526+' : '暂无'" />
      <order-info-item v-else label="司机" :value="driver(orderInfo.driverType)" />
      <order-info-item label="司机电话" :value="orderInfo.driverPhone || '暂无'" />
      <template v-if="orderInfo.driverType !=2 && !orderInfo.outwardVehicleRealPrice">
        <order-info-item label="司机状态" :value="orderInfo.driverConfirmStatusLabel" />
        <order-info-item label="司机备注" :value="orderInfo.driverRemark || '暂无'" />
      </template>
    </view>
  </view>
</template>

<script>
import OrderInfoItem from '../order-info-item/order-info-item'
import { driverType } from '../../index'
import { carDegreeList } from '@/vehicle/index'
export default {
  name: 'VehicleInfo',
  components: {
    OrderInfoItem
  },
  props: {
    orderInfo: {
      type: Object,
      default: () => {}
    }
  },
  computed: {
    driver() {
      return (type) => {
        const name = this.orderInfo.driverName
        if (type || type === 0) {
          if (type === 0) {
            return name || '暂无'
          } else {
            for (let i = 0; i < driverType.length; i++) {
              const item = driverType[i]
              if (type === item.value) return name ? `${name}(${item.label}司机)` : '暂无'
            }
          }
        }
        return '暂无'
      }
    },
    vehicleType() {
      let type = ''
      const info = this.orderInfo
      carDegreeList.forEach(item => {
        if (item.value === this.orderInfo.autoClass) type = item.label
      })
      return info.vehicleId ? info.autoBrand + info.seatAmount + '座(' + type + ')' : '暂无'
    }
  }
}
</script>

<style scoped lang="scss">
@include setMargin(top,14);
</style>
